@extends('admin/layout')

@section('content')
    <script>
        function del()
        {
            if(confirm("确定要删除吗？"))
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    </script>
   
    <div class="content-wrapper">
        <!-- Content Header (Page header) -->
        <section>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> 首页</a></li>
                <li><a href="#">商品管理</a></li>
                <li class="active">商品列表</li>
            </ol>
            <div class="input-group margin">
                <form action="{{ url('admin/goodsList') }}" method="post" >
                    {{ csrf_field() }}
                    <select style="width: 150px"  name="searchtype" class="form-control">
                        @foreach($searchtype as $value)
                            <option value="{{ $value['id'] }}">{{ $value['searchtype'] }}</option>
                        @endforeach
                    </select>
                    <input style="width: 200px"  name="param" type="text" class="form-control">
                    <input  type="submit" class="btn btn-info btn-flat" value="Go!">
                </form>
            </div>
        </section>

        <!-- Main content -->
        <section class="content">
            <div class="row">
                <div class="col-md-12" style="width: 100%;">
                    <div class="box">
                        <div class="box-header with-border">
                            <h3 class="box-title">内容</h3>
                        </div>
                        <span id="msg" style="display: none">
                            @if (count($errors) > 0)
                                @foreach ($errors->all() as $error)
                                    <div style="width: 100%;">
                                    <span style="color: red;display: block;margin: 0px auto;width: 200px;text-align: center;">{{ $error }}</span>
                                </div>
                                @endforeach
                            @endif
                        </span>
                        <script type="text/javascript">
                            var _msg = $('#msg div span').text();
                            console.log(_msg);
                            if(_msg != ''){
                                layer.msg(_msg);
                            }
                        </script>
                        <!-- /.box-header -->
                        <div class="box-body" style="overflow: auto;">
                            <form action="{{ url('admin/goods/batchDel') }}" method="post" >
                                {{ csrf_field() }}
                                <table class="table table-bordered"  style=" text-align: center;">
                                    <tr>
                                        <th style=" text-align: center;">@</th>
                                        @foreach($searchtype as $value)
                                            <th style=" text-align: center;min-width: 75px;">{{ $value['searchtype'] }}</th>
                                        @endforeach
                                        <th style=" text-align: center;">商品详图</th>
                                        <th style=" text-align: center;min-width: 150px;">操作</th>
                                    </tr>
                                    @foreach($list as $value)
                                        <tr>
                                            <td><input type="checkbox" name="id[]" value="{{ $value->id }}" /></td>
                                            <td>{{ $value->id}}</td>
                                            <td>{{ $value->rank}}</td>
                                            <td>{{ $value->create_time}}</td>
                                            <td>{{ $value->update_time}}</td>
                                            <td>{{ $value->goods_name}}</td>
                                            <td>{{ App\Category::find($value->category_id)['name'] }}</td>
                                            <td>{{ $value->goods_introduce}}</td>
                                            <td>{{ $value->goods_price}}积分</td>
                                            {{--<td>{{ App\Lable::find($value->lable)['name'] }}</td>--}}
                                            <td>{{ $value->goods_inventory}}</td>
                                            <td><img src="{{ asset('productImg/'.$value["goods_picture"])}}" alt="无图片" width="93" height="117" /></td>
                                            <td>
                                                <a class="btn btn-warning btn-xs"  href="{{ url('admin/goods/getGoods/'.$value['id']) }}">修改<a>
                                                        <a class="btn btn-danger btn-xs" href="{{ url('admin/goods/delGoods/'.$value['id']) }}" onclick='return del()'>删除<a>
                                            </td>
                                        </tr>
                                    @endforeach
                                </table>
                                <input type="submit" class="btn btn-danger btn-sm"  onclick='return del()' value="批量删除"/>
                            </form>
                        </div>
                        <div calss="pages" style="text-align: center;">
                            {{ $list->links() }}
                        </div>
                        <!-- /.box -->
                    </div>
                    <!-- /.row -->
                </div>
            </div>
        </section>
        <!-- /.content -->
    </div>
    <!-- /.content-wrapper -->
  
@stop